package org.fujay.langchain4jserver.infrastructure.persistence.mybatis.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.fujay.mybatis.core.base.BaseEntity;

import java.time.LocalDateTime;

/**
 * 模型配置持久化实体 (对应 model_setting 表)
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "model_setting")
public class ModelPo extends BaseEntity {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @TableField(value = "model_supplier")
    private String modelSupplier;

    @TableField(value = "supplier_name")
    private String supplierName;

    @TableField(value = "model_name")
    private String modelName;

    @TableField(value = "model_type")
    private String modelType; // 对应 ModelType.code

    @TableField(value = "response_format")
    private Integer responseFormat; // 对应 ModelConfig.responseFormat

    @TableField(value = "base_url")
    private String baseUrl; // 对应 ModelConfig.baseUrl

    @TableField(value = "api_key")
    private String apiKey; // 对应 ModelConfig.apiKey

    @TableField(value = "secret_key")
    private String secretKey; // 对应 ModelConfig.secretKey

    @TableField(value = "temperature")
    private Double temperature; // 对应 ModelConfig.temperature

    @TableField(value = "top_k")
    private Integer topK; // 对应 ModelConfig.topK

    @TableField(value = "top_p")
    private Double topP; // 对应 ModelConfig.topP

    @TableField(value = "max_tokens")
    private Integer maxTokens; // 对应 ModelConfig.maxTokens

    @TableField(value = "num_ctx")
    private Integer numCtx; // 对应 ModelConfig.numCtx

    @TableField(value = "time_out")
    private Integer timeOut; // 对应 ModelConfig.timeOut (秒)

    @TableField(value = "max_retries")
    private Integer maxRetries; // 对应 ModelConfig.maxRetries

    @TableField(value = "max_memory")
    private Integer maxMemory; // 对应 ModelConfig.maxMemory

    @TableField(value = "log_requests")
    private Boolean logRequests; // 对应 ModelConfig.logRequests

    @TableField(value = "log_responses")
    private Boolean logResponses; // 对应 ModelConfig.logResponses

    @TableField(value = "enable") // 注意这里是小写 'e'
    private boolean enabled; // 对应 Model.enabled

    @TableField(value = "last_test_time")
    private LocalDateTime lastTestTime; // 对应 ConnectionStatus.lastTestTime

    /**
     * 0: 未测试 (UNTESTED) 1: 成功 (SUCCESS) 2: 失败 (FAILED)
     */
    @TableField(value = "last_test_status")
    private Integer lastTestStatus; // 对应 ConnectionStatus.lastTestResult

    /**
     * 逻辑删除标识
     */
    @TableField(value = "del_flag")
    @TableLogic
    private Integer delFlag;
}
